/*
 *
 * This file is part of the open-source SeetaFace engine, which includes three modules:
 * SeetaFace Detection, SeetaFace Alignment, and SeetaFace Identification.
 *
 * This file is part of the SeetaFace Detection module, containing codes implementing the
 * face detection method described in the following paper:
 *
 *
 *   Funnel-structured cascade for multi-view face detection with alignment awareness,
 *   Shuzhe Wu, Meina Kan, Zhenliang He, Shiguang Shan, Xilin Chen.
 *   In Neurocomputing (under review)
 *
 *
 * Copyright (C) 2016, Visual Information Processing and Learning (VIPL) group,
 * Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China.
 *
 * The codes are mainly developed by Shuzhe Wu (a Ph.D supervised by Prof. Shiguang Shan)
 *
 * As an open-source face recognition engine: you can redistribute SeetaFace source codes
 * and/or modify it under the terms of the BSD 2-Clause License.
 *
 * You should have received a copy of the BSD 2-Clause License along with the software.
 * If not, see < https://opensource.org/licenses/BSD-2-Clause>.
 *
 * Contact Info: you can send an email to SeetaFace@vipl.ict.ac.cn for any problems.
 *
 * Note: the above information must be kept whenever or wherever the codes are used.
 *
 */

#ifndef SEETA_FD_FEAT_LAB_FEATURE_MAP_H_
#define SEETA_FD_FEAT_LAB_FEATURE_MAP_H_



#include "feature_map.h"
#include "surf_feature_map.h"
/** @struct LABFeature
 *  @brief Locally Assembled Binary (LAB) feature.
 *
 *  It is parameterized by the coordinates of top left corner.
 */

typedef struct LABFeature {
  int32_t x;
  int32_t y;
} LABFeature;
typedef struct classLABFeatureMap LABFeatureMap;
struct classLABFeatureMap{

   int32_t rect_width_;
   int32_t rect_height_;
   int32_t num_rect_;
  uint8_t* feat_map_gpu_;
  int32_t* rect_sum_;
 int32_t* int_img_;
  uint32_t* square_int_img_;
  FeatureMap featuremap;
  SURFFeatureMap surffeaturemap;
};
void ReleaseLABFeatureMap(struct classLABFeatureMap *p);
void LABFeatureMapCompute(struct classLABFeatureMap *p, const uint8_t* input, int32_t width, int32_t height);
float LABFeatureMapGetStdDev(struct classLABFeatureMap *p);
void LABFeatureMapSetROI(struct classLABFeatureMap *p, const Rect  roi);
void LABFeatureMemInit(struct classLABFeatureMap* p, int32_t width, int32_t height,FDHandle* handle);

void LABFeatureMapReshape(struct classLABFeatureMap *p, int32_t width, int32_t height);
void LABFeatureMapComputeIntegralImages(struct classLABFeatureMap *p, const uint8_t* input);
void LABFeatureMapComputeRectSum(struct classLABFeatureMap *p);
void LABFeatureMapComputeFeatureMap(struct classLABFeatureMap *p);
//void InitLABFeatureMap(struct classLABFeatureMap *p, int32_t rect_width = 3, int32_t rect_height = 3, int32_t num_rect = 3);
void InitLABFeatureMap(struct classLABFeatureMap *p, int32_t rect_width , int32_t rect_height , int32_t num_rect );
uint8_t LABFeatureMapGetFeatureVal(struct classLABFeatureMap *p, int32_t offset_x, int32_t offset_y);
uint8_t* LABFeatureMapGetFeatureValGPU(struct classLABFeatureMap *p);
int32_t* LABFeatureMapGet_int_imgGPU(struct classLABFeatureMap *p);
uint32_t* LABFeatureMapGet_square_int_imgGPU(struct classLABFeatureMap *p);

int32_t LABFeatureMapGet_Featoffset(struct classLABFeatureMap *p);

int32_t LABFeatureMapGetWidth(struct classLABFeatureMap *p);

int32_t LABFeatureMapGetHeight(struct classLABFeatureMap *p);

//template<typename Int32Type>
#define Int32Type int
void Integral(struct classLABFeatureMap *p, Int32Type* data);


#endif  // SEETA_FD_FEAT_LAB_FEATURE_MAP_H_
